package app.service.sys;

import org.springframework.stereotype.Repository;

import app.model.sys.SysRoleMenu;
import app.util.StringUtil;
import base.service.RepositoryService;

@Repository
public class SysRoleMenuService extends RepositoryService<SysRoleMenu> {

	public void saveSysRoleMenu(String menuIds, String roleId) throws Exception {
		
		String hql = "DELETE FROM SysRoleMenu WHERE roleId = '"+roleId+"'";
		getDao().executeHql(hql);
		
		if(StringUtil.isNotEmpty(menuIds)){
			String[] menuIdsArray = menuIds.split(",");
			for (int i = 0; i < menuIdsArray.length; i++) {
				String menuId = menuIdsArray[i];
				SysRoleMenu sysRoleMenu = new SysRoleMenu();
				sysRoleMenu.setMenuId(menuId);
				sysRoleMenu.setRoleId(roleId);
				getDao().save(sysRoleMenu);
			}
		}
		throw new RuntimeException("123");
	}

}
